package org.haifi.game;

import javax.annotation.PostConstruct;

import org.haifi.game.model.GameServer;
import org.haifi.game.model.MapInstance;
import org.haifi.game.model.ServerType;
import org.haifi.game.service.MapInstanceManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 存储服务器中的各种静态常量
 * 
 * @author joycube2
 * 
 */
@Component
public class GameContext {
	/**
	 * 当前服务器类型
	 */
	private static ServerType serverType = null;

	/**
	 * 网关服务器
	 */
	private static GameServer gateWayServer;

	/**
	 * 出生地图
	 */
	private static MapInstance bornMap;

	@PostConstruct
	public void init() {
		// 出生点地图
		bornMap = mapInstanceManager.getBornMap();
	}

	public static MapInstance getBornMap() {
		return bornMap;
	}

	public static GameServer getGateWayServer() {
		return gateWayServer;
	}

	/**
	 * true:当前服务器是游戏服
	 * 
	 * @return
	 */
	public static boolean isGameServer() {
		return ServerType.GAME.equals(serverType);
	}

	/**
	 * true:当前服务器是网关
	 * 
	 * @return
	 */
	public static boolean isGateWay() {
		return ServerType.GATE_WAY.equals(serverType);
	}

	/**
	 * true:当前服务器是跨服战服
	 * 
	 * @return
	 */
	public static boolean isTournament() {
		return ServerType.TOURNAMENT.equals(serverType);
	}

	@Autowired
	private MapInstanceManager mapInstanceManager;
}
